package net.piggy.http;

import java.io.IOException;
import java.util.Properties;

public class Config {
    public final static String TIME = "TIME";
    private Config(){}
    private static volatile Config configParam;
    public static Config getConfigParam() throws IOException {
        if(configParam==null){
            synchronized (Config.class){
                if(configParam==null){
                    configParam = new Config();
                    Properties prop = new Properties();
                    prop.load(Config.class.getClassLoader().getResourceAsStream("application.properties"));
                    configParam.setIp(prop.getProperty("ip"));
                    configParam.setPort(Integer.parseInt(prop.getProperty("port")));
                    configParam.setTargetPort(Integer.parseInt(prop.getProperty("target.port")));
                    configParam.setTargetIp(prop.getProperty("target.ip"));
                }
            }
        }
        return configParam;
    }

    private String ip;
    private int port;
    private String targetIp;
    private int targetPort;

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getTargetPort() {
        return targetPort;
    }

    public void setTargetPort(int targetPort) {
        this.targetPort = targetPort;
    }

    public String getTargetIp() {
        return targetIp;
    }

    public void setTargetIp(String targetIp) {
        this.targetIp = targetIp;
    }
}
